package com.itheima.io1.mybyteststream2;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Arrays;

/**
 * @author zhangbaiyan
 * @date 2024-09-20 13:16
 * @description:
 * @version:
 */
public class test4 {
    public static void main(String[] args) throws IOException {
        /*
        public int read(byte[] buffer) 依次读一个字节数组数据
         */


        //1/创建对象
        FileInputStream fis = new FileInputStream("a.txt");
        //2.读取数据
        byte[] b = new byte[2];
        //依次读取多个字节数据,具体读多少,跟数组长度有关
        //返回值:本次读取到了多少个字节数据
        int len = fis.read(b);
        System.out.println(len);
        String str = new String(b,0,len);
        System.out.println(str);
        //3.释放资源
        fis.close();

    }
}
